<?php session_start(); ?>
<?php
include('../ketnoi.php');
if (!$_SESSION['user']) header("location: index.php"); // nếu biến session['banguyen'] chưa có thì trở về trang đăng nhập, copy dòng này vào trang nào muốn bảo vệ bằng mật khẩu
?>

<script language="javascript">	
	function xoa(){
	 if (document.adminForm.boxchecked.value == 0){
		  alert('Please make a selection from the list to delete'); 
     } 
	 else if (confirm('Bạn có chác muốn xóa không?')){ 
	      document.adminForm.submit();
     }

	}
	function sua(){
		  alert('Không thể sửa vì khóa học này đã khai giảng!!!');
		  return false;
	}
	function inan(){
		  alert('Không thể in, Chưa có học viên đăng ký!!!');
		  return false;
	}
</script>
<script type="text/javascript" src="script/common.js"></script>
<script type="text/javascript" src="script/viettyping.js"></script>
<script type="text/javascript" src="script/joomla.js"></script>

<style type="text/css">
<!--
.error, .success {padding:.8em; margin-bottom:.5em;border:2px solid #AAF;width:625px; text-align:center}
.error {background: #ECECFF;color: red;border-color:#AAF;}
.success {background: #ECECFF;color: #00F;border-color:#AAF;}
-->
.xem {
FONT-SIZE: 13px; 
	COLOR: #0000FF;
	font-weight: bold;
	background-color:#FFFFFF;
}
.xem a {
	color: #0000FF;
	text-decoration: none;
}
.xem a:link, a:visited {
	color: #0000FF;
	text-decoration: none;
}
</style>
<script language="javascript">
            document.getElementById('txtKhoa').focus();
 </script> 
<script type="text/javascript" src="scripts/joomla.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script src="ckeditor/_samples/sample.js" type="text/javascript"></script>
<div class="m">
 <?php 
    $shop=$dulieu;
	if($_GET['action']=='view' && $_GET['option']=='com_lichhoc')
	{
		$sql1 = "SELECT * FROM `".$shop."`.`lichhoc` order by L_STT asc";
		$ketqua = mysql_query($sql1) or die ('khong tim thay du lieu');
		$tong=mysql_num_rows($ketqua);
		if($_POST['limit']==""){$sotrang = ceil($tong/20);}else{
		$sotrang = ceil($tong/$_POST['limit']);}
	    $dem = -1;
		
	if(isset($_POST['trang'])){
	 $trang = $_POST['trang'];
	}else{	
     if(isset($_POST['end'])){
	  $trang =$sotrang;
	 }else{
	  if(isset($_POST['start'])){
	   $trang =1;
	  }else{
	   $trang=1;
	  }
	 }	
	}
?>
<div id="menu">
	<div style="float: right;">
	<div class="icon1">
<a  class="toolbar" href="index.php"><img src="images/toolbar/icon-32-cancel.png" alt="Remove"><br><span>Cancel</span></a>
	</div>
	</div>

	
	<div style="float: right;">
	<div class="icon1">
<a class="toolbar" href="?option=com_lichhoc&action=insert"><img src="images/toolbar/icon-32-new.png" alt="New"><br><span>New</span></a>
	</div>
	</div>
</div>

<div class="header" style="background: url(images/dashboard/icon-48-article.png) no-repeat scroll 0% 0% transparent; text-indent: 30px; line-height: 50px;">
  <h2 style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;Lịch khai giảng các khóa nghiệp vụ</h2></div><br /><br />
<form name="adminForm" action="" method="post">
					
					<input name="option" value="com_lichhoc" type="hidden">
					<input name="boxchecked" type="hidden">
					<input name="task" value="" type="hidden">
					<input name="func" value="" type="hidden">
<table width="828" border="0" cellpadding="" cellspacing="3">
					   	<tr >
					   	
						<td width="367">Lọc 
                      <select name="trangthai" id="filter_state" class="inputbox" size="1" onchange="adminForm.submit();">
					  <option value="" selected="selected">- Chọn trạng thái lịch-</option>
					  <option value="0">Chưa khai giảng</option>
					  <option value="1">Đã khai giảng</option>
                      <option value="">Tất cả</option>
					  </select>	
						
                      <select name="khoa" id="filter_state" class="inputbox" size="1" onchange="adminForm.submit();">
					  <option value="" selected="selected">- Chọn khóa nghiệp vụ -</option>
                      <?php
		$sql1 = "SELECT * FROM `".$shop."`.`lophoc` order by MaLopHoc asc";
		$k = mysql_query($sql1) or die ('khong tim thay du lieu');
		 while($t = mysql_fetch_array($k))
	     { 
	  ?>
      <option value="<?php echo $t['MaLopHoc']?>"><?php echo $t['TenLopHoc']?></option>
      <?php
	   }
					   ?>
                       
					  
                      
                      <option value="">Tất cả</option>
					  </select>		
						</td>
                        <td width="127" align="right">
						  <select name="thang" id="mh" style="min-width:50px;">
                          <option value="" selected="selected">- Chọn tháng -</option>
      <option value="01">1</option><option value="02" >2</option>
      <option value="03">3</option><option value="04" >4</option>
      <option value="05">5</option><option value="06" >6</option>
      <option value="07">7</option><option value="08" >8</option>
      <option value="09">9</option><option value="10" >10</option>
      <option value="11">11</option><option value="12">12</option>
	  </select>
	  </select></td>
						
				  	
					    <td width="322" valign="bottom"><input type="submit" name="bt_fillter" value="Lọc dữ liệu"  style="border:1px solid #CCCCCC; background-color:#F5F5F5; font-weight:bold; color:#0033CC"/>  </td>
					   	</tr>
                        <tr>
<td colspan="3">&nbsp;
</td>
</tr>	 	
					</table>
                    
<table class="adminlist" width="100%">
<tbody><tr><th width="2%" class="title">#</th>
<th width="3%" class="title"><input name="toggle" value="" onclick="checkAll(<?php if($_POST['limit']==""){echo '20';}else{echo $_POST['limit']; } ?>)" type="checkbox"></th>
<th class="title" width="22%">Khóa học</th>  
<th class="title" width="5%"> Khóa</th>	 	 	 	 	 	 	 	  	 	  
<th class="title" width="12%">Khai giảng</th>
<th class="title" width="11%"> Số lượng ĐK tối đa</th>
<th class="title" width="6%"> Đã đăng ký</th>
<th class="title" width="4%"> In DS</th>
<th class="title" width="20%"> Thời gian</th> 
<th class="title" width="7%"> Đăng ký</th>  	
<th width="4%" class="title"> Sửa</th>
<th class="title" width="4%"> Xóa</th>
</tr>
 <?php 
	$stt=0;
	$t=0;
   while($dongDL = mysql_fetch_array($ketqua))
	  { 
	  $dem++;
	    if($_POST['limit']==""){$s=20;}
		else{$s=$_POST['limit'];}
		if($dem >= ($trang-1)*$s && $dem <= ($trang*$s)-1)
		{
  ?>
  
<tr class="row<?php echo $t ?>">
<td align="center"><?php echo $dem+1 ?></td>
<td align="center"><input id="cb<?php echo $stt ?>" name="product_id[<?php echo $dongDL['L_STT']?>]" value="<?php echo $dongDL['L_STT']?>" onclick="isChecked(this.checked);" type="checkbox"></td>
<td>
<?php
		$sql1 = "SELECT * FROM `".$shop."`.`lophoc` where MaLopHoc ='".$dongDL['MaLopHoc']."'";
		$k = mysql_query($sql1) or die ('khong tim thay du lieu');
		$t = mysql_fetch_array($k);
        echo $t['TenLopHoc'];
?>
</td>   	 	 	 	 	 	
<td><?php echo $dongDL['L_KHOA']?></td>
<td><?php  echo substr($dongDL['L_NGAYKG'],8,2)."/".substr($dongDL['L_NGAYKG'],5,2)."/".substr($dongDL['L_NGAYKG'],0,4).' &nbsp;';  ?></td>
<td ><?php echo $dongDL['L_SLUONG']?></td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td >
<?php
		$sql1 = "SELECT * FROM `".$shop."`.`thoigian` where TG_MA ='".$dongDL['TG_MA']."'";
		$k = mysql_query($sql1) or die ('khong tim thay du lieu');
		$t = mysql_fetch_array($k);
        echo $t['TG_NOTE'].' ('.$t['TG_FROM'].'-'.$t['TG_TO'].')';
?>
</td>
<td class="order" align="center">&nbsp;</td>

<td align="center"><a href="?option=com_lichhoc&action=update&amp;id=<?php echo $dongDL['L_STT'] ?>"><img src="images/edit_f2.png" width="20" height="20" name="Edit<?php echo $stt+1 ?>" alt="Edit" border="0"></a></td>
<td align="center"><a class="toolbar" href="?option=com_lichhoc&action=delete&amp;id=<?php echo $dongDL['L_STT'] ?>" onclick="return confirm('Bạn có chắc chắn muốn xóa?');"><img src="images/delete_f2.png" width="20" height="20"alt="Delete" name="delete<?php echo $stt+1 ?>" align="middle" border="0"></a></td>
</tr>
	 <?php
	 $stt=$stt+1;
	 if($t==0)$t=1;
	 else $t=0;
	 }
	  }//ket thuc ham while in du lieu
	  ?>
</tbody></table>

<table class="adminlist"><tbody>
<?php if($sotrang > 1 && $keyword==""){?>
<tr>
  <td colspan="3" align="center"> 
  <input name="start" class="button2" type="submit" value="Start"/>
  <?php
for($i=1; $i<=$sotrang; $i++)
{ ?>
	<input name="trang" class="button" type="submit" value="<?php echo $i;?>"/>
<?php 
}
?>
<input name="end" class="button2" type="submit" value="End"/></td></tr>
<?php } ?>
<?php 
if($keyword=="" && $coso=='' && $trangthai==''){
?>
<tr><td width="48%" align="right" nowrap="nowrap">Display #</td><td>
<select class="inputbox" name="limit" size="1" onchange="this.form.submit();">
<option value="5"  <?php if($_POST['limit']==5) echo "selected='selected'" ?>>5</option>
<option value="10" <?php if($_POST['limit']==10) echo "selected='selected'" ?>>10</option>
<option value="15" <?php if($_POST['limit']==15) echo "selected='selected'" ?>>15</option>
<option value="20" <?php if($_POST['limit']=='') echo "selected='selected'" ?>>20</option>
<option value="25" <?php if($_POST['limit']==25) echo "selected='selected'" ?>>25</option>
<option value="30" <?php if($_POST['limit']==30) echo "selected='selected'" ?>>30</option>
<option value="50" <?php if($_POST['limit']==35) echo "selected='selected'" ?>>50</option>
</select>
</td><td width="48%" align="left" nowrap="nowrap">Results 1 - 
<?php if($_POST['limit']==''){if($tong < 20 ){echo $tong;}else echo '20';} else{if($_POST['limit'] > $tong ){echo $tong;}else echo $_POST['limit'];}?> of <?php echo $tong ?></td></tr>
<?php }else{
?>
<tr><td width="48%" align="right" nowrap="nowrap">Display #</td><td>
<select class="inputbox" name="limit" size="1" disabled="disabled">
<option><?php echo $tong1; ?></option>
</select>
</td><td width="48%" align="left" nowrap="nowrap"><?php if($tong1 >0){?>Results 1 - 
<?php echo $tong1;?> of <?php echo $tong1; }?></td></tr>
<?php
}
?>
</tbody></table>
</form>
<?php
}//ket thuc view

if($_GET['action']=='delete' && $_GET['option']=='com_lichhoc')
	{
		  $sql = "Delete from `".$shop."`.`lichhoc` where L_STT = '".$_GET['id']."'";
		  $delete = mysql_query($sql);
          echo"<script language=javascript>window.location='index.php?option=com_lichhoc&action=view';</script>";
	  }// ket thuc kiem tra action Delete
	  
 
if($_GET['action']=='insert' && $_GET['option']=='com_lichhoc')
{
if(isset($_POST['txtKhoa'])){
	$error="";
	if($_POST['txtKhoa']=="" || $_POST['txtBuoi']=="" || $_POST['txtSlg']=="" || $_POST['ngay1']=="" || $_POST['ngay2']=="" || $_POST['thang1']=="" || $_POST['thang2']=="" || $_POST['nam1']=="" || $_POST['nam2']==""){
	  $error="Vui lòng nhập đầy đủ các field.";
    }else{ 
		$hh=$_POST['nam1']."-".$_POST['thang1']."-".$_POST['ngay1'];
	    $dk=$_POST['nam2']."-".$_POST['thang2']."-".$_POST['ngay2'];
	    $sql = "INSERT INTO `".$shop."`.`lichhoc` (`MaLopHoc`,`L_SLUONG`,`TG_MA`,`L_NGAYHHDK`,`L_NGAYKG`,`L_NGAYDANG`,`NV_MA`) VALUES ('".$_POST['txtKhoa']."','".$_POST['txtSlg']."','".$_POST['txtBuoi']."','".$hh."','".$dk."',now(),'". $_SESSION['user']."');";
		$insert = mysql_query($sql);
        echo"<script language=javascript>window.location='index.php?option=com_lichhoc&action=view';</script>";
	}
}   	 	 	 	 	 	 	 	 

				    

	?>
	<div id="menu">
	<div style="float: right;">
	<div class="icon1">
<a  class="toolbar" href="?option=com_lichhoc&action=view"><img src="images/toolbar/icon-32-cancel.png" alt="Remove"><br><span>Cancel</span></a>
	</div>
	</div>
	
	<div style="float: right;">
	<div class="icon1">
<a class="toolbar" onclick="adminForm2.submit();"><img src="images/toolbar/icon-32-save.png"  alt="New"><br><span>Save</span></a>
	</div>
	</div>
</div>

<div class="header" style="background: url(images/dashboard/icon-48-section.png)  no-repeat scroll 0% 0% transparent; text-indent: 30px; line-height: 50px;">
  <h2 style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;Lịch khai giảng: [ Thêm mới ]</h2>
</div><br /><br />
<?php
	if($error!=""){
	?>
	 <div class="error" align="center"><img src='../images/cancel_f2.png' width='10px' height='10px'/> <?php echo $error ?></div>
  <?php
  }
?>
	<form name="adminForm2" action="" method="post" enctype="multipart/form-data">

<div style="height: auto; width: 1012px;" id="ext-gen37">
<div class="tab-page" id="info-page">
<table style=" width:60%;" class="adminform">
	<tbody><tr> 
   		<td width="100%" valign="top">
	    <table width="100%" border="0">
      			<tbody>                <tr> 
       				<td colspan="2" align="left"><span style="font-weight:bold; font-size:14px; color:#00F">Thông tin lịch khai giảng 	 	 	 </span></td>
    			</tr>

    			<tr class="row1"> 
      				<td width="29%"><div style="text-align: right; font-weight: bold;">
   					  Khóa học:</div>      				</td>
      				<td width="71%"> 
       				<select name="txtKhoa" id="txtKhoa"  tabindex="1" class="textbox" style="width:300px;margin-left:10px" >
                    <option value="">Chọn khóa học</option>
                                 
                                        <?php
		$sql1 = "SELECT * FROM `".$shop."`.`lophoc` order by MaLopHoc asc";
		$k = mysql_query($sql1) or die ('khong tim thay du lieu');
		 while($t = mysql_fetch_array($k))
	     { 
	  ?>
      <option value="<?php echo $t['MaLopHoc']?>"><?php echo $t['TenLopHoc']?></option>
      <?php
	   }
					   ?>
  
                    </select>
</td>
    			</tr>
    			<tr class="row0"> 
      				<td width="29%"><div style="text-align: right; font-weight: bold;">
					Buổi học:</div>      				</td>
      				<td width="71%">       				
                    <select name="txtBuoi" id="txtBuoi"  tabindex="2" class="textbox" style="width:300px; margin-left:10px">
                    <option value="">Chọn buổi học</option>
<?php
		$sql1 = "SELECT * FROM `".$shop."`.`thoigian` ";
		$k = mysql_query($sql1) or die ('khong tim thay du lieu');
		while($t = mysql_fetch_array($k))
	     { 
	  ?>
      <option value="<?php echo $t['TG_MA']?>"><?php echo $t['TG_NOTE'].' ('.$t['TG_FROM'].'-'.$t['TG_TO'].')'; ?></option>
      <?php
	   }
        
?>
                    </select></td>
    			</tr>
    			<tr class="row1"> 
      				<td width="29%"><div style="text-align: right; font-weight: bold;">Số lượng ĐK tối đa:</div>      				</td>
      				<td width="71%"><input style="width:250px; margin-left:10px" name="txtSLg" id="txtSLg" type="text" onKeyPress="return onlyNumber(event);" value=""  tabindex="3"/> học viên</td>
    			</tr>


				<tr class="row0"> 
      				<td width="29%"><div style="text-align: right; font-weight: bold;">
					Ngày hết hạn:</div>      				</td>
      				<td width="71%">
    <label style="margin-left:10px;">Ngày 
    <select name="ngay1">
          <option value="01">1</option><option value="02" >2</option>
      <option value="03">3</option><option value="04" >4</option>
      <option value="05">5</option><option value="06" >6</option>
      <option value="07">7</option><option value="08" >8</option>
      <option value="09">9</option><option value="10" >10</option>
      <option value="11">11</option><option value="12">12</option>
      <option value="13">13</option><option value="14" >14</option>
      <option value="15">15</option><option value="16" >16</option>
      <option value="17">17</option><option value="18" >18</option>
      <option value="19">19</option><option value="20" >20</option>
      <option value="09">9</option><option value="22" >22</option>
      <option value="21">21</option><option value="24">24</option>
            <option value="25">25</option><option value="26" >26</option>
      <option value="27">27</option><option value="28" >28</option>
      <option value="29">29</option><option value="30">30</option>
    </select>
     </label>
      
      <label>Tháng 
      <select name="thang1" id="mh" style="min-width:50px;">
      <option value="01">1</option><option value="02" >2</option>
      <option value="03">3</option><option value="04" >4</option>
      <option value="05">5</option><option value="06" >6</option>
      <option value="07">7</option><option value="08" >8</option>
      <option value="09">9</option><option value="10" >10</option>
      <option value="11">11</option><option value="12">12</option>
	  </select>
      </label>
      
      <label>Năm 
      <select name="nam1">
<option><?php echo date('Y') ?></option>
      </select>
      </label> 
                    </td>
    			</tr>
				 <tr class="row1"> 
				   <td width="29%"><div style="text-align: right; font-weight: bold;">Ngày khai giảng:</div>      				</td>
				   <td width="71%">    
     <label style="margin-left:10px;">Ngày 
    <select name="ngay2">
      <option value="01">1</option><option value="02" >2</option>
      <option value="03">3</option><option value="04" >4</option>
      <option value="05">5</option><option value="06" >6</option>
      <option value="07">7</option><option value="08" >8</option>
      <option value="09">9</option><option value="10" >10</option>
      <option value="11">11</option><option value="12">12</option>
            <option value="13">13</option><option value="14" >14</option>
      <option value="15">15</option><option value="16" >16</option>
      <option value="17">17</option><option value="18" >18</option>
      <option value="19">19</option><option value="20" >20</option>
      <option value="09">9</option><option value="22" >22</option>
      <option value="21">21</option><option value="24">24</option>
            <option value="25">25</option><option value="26" >26</option>
      <option value="27">27</option><option value="28" >28</option>
      <option value="29">29</option><option value="30">30</option>
    </select>
     </label>
      
      <label>Tháng 
      <select name="thang2" id="mh" style="min-width:50px;">
      <option value="01">1</option><option value="02" >2</option>
      <option value="03">3</option><option value="04" >4</option>
      <option value="05">5</option><option value="06" >6</option>
      <option value="07">7</option><option value="08" >8</option>
      <option value="09">9</option><option value="10" >10</option>
      <option value="11">11</option><option value="12">12</option>
	  </select>
      </label>
      
      <label>Năm 
      <select name="nam2">
<option><?php echo date('Y') ?></option>
      </select>
      </label> 
      </td>
			    </tr>

    			  <tr class="row0"> 
    					    
		      		<td valign="top" width="29%">&nbsp;</td>
		      		<td width="71%">&nbsp;</td>		    
	    			</tr>
	  			  </table>
 		</td>
  	</tr>
</tbody></table>

</div>
</div>
</form>
<?php
}// ket thuc kiem tra action insert



if($_GET['action']=='update' && $_GET['option']=='com_lichhoc')
	{
		$sql ="SELECT * from `".$shop."`.`lichhoc` where L_STT = '".$_GET['id']."'";
		$ketqua = mysql_query($sql);
		$dulieu = mysql_fetch_array($ketqua);
		$ngay1=substr($dulieu['L_NGAYHHDK'],8,2);
		$thang1=substr($dulieu['L_NGAYHHDK'],5,2);
		$nam1=substr($dulieu['L_NGAYHHDK'],0,4);
		$ngay2=substr($dulieu['L_NGAYKG'],8,2);
		$thang2=substr($dulieu['L_NGAYKG'],5,2);
		$nam2=substr($dulieu['L_NGAYKG'],0,4);
	if(isset($_POST['txtKhoa'])){ 
	$error="";
	if($_POST['txtKhoa']=="" || $_POST['txtBuoi']=="" || $_POST['txtSlg']=="" || $_POST['ngay1']=="" || $_POST['ngay2']=="" || $_POST['thang1']=="" || $_POST['thang2']=="" || $_POST['nam1']=="" || $_POST['nam2']==""){
	  $error="Vui lòng nhập đầy đủ các field.";
    }else{ 
		$hh=$_POST['nam1']."-".$_POST['thang1']."-".$_POST['ngay1'];
	    $dk=$_POST['nam2']."-".$_POST['thang2']."-".$_POST['ngay2'];
         $sql = "UPDATE `".$shop."`.`lichhoc` SET  `MaLopHoc` = '".$_POST['txtKhoa']."',`L_SLUONG` = '".$_POST['txtSlg']."',`TG_MA` = '".$_POST['txtBuoi']."',`L_NGAYHHDK` = '".$hh."',`L_NGAYKG` = '".$dk."' WHERE `coso`.`L_STT` = '".$_GET['id']."'";
		 
		  
		 $update = mysql_query($sql) or die($sql);
         echo"<script language=javascript>window.location='index.php?option=com_lichhoc&action=view';</script>";
	}
}
	?>
<div id="menu">
	<div style="float: right;">
	<div class="icon1">
<a  class="toolbar" href="?option=com_lichhoc&action=view"><img src="images/toolbar/icon-32-cancel.png" alt="Remove"><br><span>Cancel</span></a>
	</div>
	</div>
	
	<div style="float: right;">
	<div class="icon1">
<a class="toolbar" onclick="adminForm3.submit();"><img src="images/toolbar/icon-32-save.png"  alt="New"><br><span>Save</span></a>
	</div>
	</div>
</div>

<div class="header" style="background: url(images/dashboard/icon-48-section.png)  no-repeat scroll 0% 0% transparent; text-indent: 30px; line-height: 50px;">
  <h2 style="margin: 0px;">&nbsp;&nbsp;&nbsp;&nbsp;Lịch khai giảng: [ Sửa ]</h2>
</div><br /><br />
<?php
	if($error!=""){
	?>
	 <div class="error" align="center"><img src='../images/cancel_f2.png' width='10px' height='10px'/> <?php echo $error ?></div>
  <?php
  }
?>
		<form name="adminForm3" action="" method="post" enctype="multipart/form-data">

<div style="height: auto; width: 1012px;" id="ext-gen37">
<div class="tab-page" id="info-page">
<table style=" width:60%;" class="adminform">
	<tbody><tr> 
   		<td width="100%" valign="top">
	    <table width="100%" border="0">
      			<tbody>                <tr> 
       				<td colspan="2" align="left"><span style="font-weight:bold; font-size:14px; color:#00F">Thông tin lịch khai giảng 	 	 	 </span></td>
    			</tr>

    			<tr class="row1"> 
      				<td width="29%"><div style="text-align: right; font-weight: bold;">
   					  Khóa học:</div>      				</td>
      				<td width="71%"> 
       				<select name="txtKhoa" id="txtKhoa"  tabindex="1" class="textbox" style="width:300px;margin-left:10px" >
                    <option value="">Chọn khóa học</option>
                                 
                                        <?php
		$sql1 = "SELECT * FROM `".$shop."`.`lophoc` order by MaLopHoc asc";
		$k = mysql_query($sql1) or die ('khong tim thay du lieu');
		 while($t = mysql_fetch_array($k))
	     { 
	  ?>
      <option value="<?php echo $t['MaLopHoc']?>" <?php if( $t['MaLopHoc'] == $dulieu['MaLopHoc']){ ?> selected="selected" <?php } ?>><?php echo $t['TenLopHoc']?></option>
      <?php
	   }
					   ?>
  
                    </select>
</td>
    			</tr>
    			<tr class="row0"> 
      				<td width="29%"><div style="text-align: right; font-weight: bold;">
					Buổi học:</div>      				</td>
      				<td width="71%">       				
                    <select name="txtBuoi" id="txtBuoi"  tabindex="2" class="textbox" style="width:300px; margin-left:10px">
                    <option value="">Chọn buổi học</option>
<?php
		$sql1 = "SELECT * FROM `".$shop."`.`thoigian` ";
		$k = mysql_query($sql1) or die ('khong tim thay du lieu');
		while($t = mysql_fetch_array($k))
	     { 
	  ?>
      <option value="<?php echo $t['TG_MA']?>" <?php if( $t['TG_MA'] == $dulieu['TG_MA']){ ?> selected="selected" <?php } ?>><?php echo $t['TG_NOTE'].' ('.$t['TG_FROM'].'-'.$t['TG_TO'].')'; ?></option>
      <?php
	   }
        
?>
                    </select></td>
    			</tr>
    			<tr class="row1"> 
      				<td width="29%"><div style="text-align: right; font-weight: bold;">Số lượng ĐK tối đa:</div>      				</td>
      				<td width="71%"><input style="width:250px; margin-left:10px" name="txtSLg" id="txtSLg" type="text" onKeyPress="return onlyNumber(event);" value="<?php echo $dulieu['L_SLUONG']?>"  tabindex="3"/> học viên</td>
    			</tr>


				<tr class="row0"> 
      				<td width="29%"><div style="text-align: right; font-weight: bold;">
					Ngày hết hạn:</div>      				</td>
      				<td width="71%">
    <label style="margin-left:10px;">Ngày 
    <select name="ngay1">
      <option value="01" <?php if( $ngay1 == 1){ ?> selected="selected" <?php } ?>>1</option><option value="02" <?php if( $ngay1 == 2){ ?> selected="selected" <?php } ?>>2</option>
      <option value="03" <?php if( $ngay1 == 3){ ?> selected="selected" <?php } ?>>3</option><option value="04" <?php if( $ngay1 == 4){ ?> selected="selected" <?php } ?>>4</option>
      <option value="05"<?php if( $ngay1 == 5){ ?> selected="selected" <?php } ?>>5</option><option value="06" <?php if( $ngay1 == 6){ ?> selected="selected" <?php } ?>>6</option>
      <option value="07" <?php if( $ngay1 == 7){ ?> selected="selected" <?php } ?>>7</option><option value="08" <?php if( $ngay1 == 8){ ?> selected="selected" <?php } ?>>8</option>
      <option value="09" <?php if( $ngay1 == 9){ ?> selected="selected" <?php } ?>>9</option><option value="10" <?php if( $ngay1 == 10){ ?> selected="selected" <?php } ?>>10</option>
      <option value="11" <?php if( $ngay1 == 11){ ?> selected="selected" <?php } ?>>11</option><option value="12" <?php if( $ngay1 == 12){ ?> selected="selected" <?php } ?>>12</option>
      <option value="13" <?php if( $ngay1 == 13){ ?> selected="selected" <?php } ?>>13</option><option value="14" <?php if( $ngay1 == 14){ ?> selected="selected" <?php } ?>>14</option>
      <option value="15" <?php if( $ngay1 == 15){ ?> selected="selected" <?php } ?>>15</option><option value="16" <?php if( $ngay1 == 16){ ?> selected="selected" <?php } ?>>16</option>
      <option value="17" <?php if( $ngay1 == 17){ ?> selected="selected" <?php } ?>>17</option><option value="18" <?php if( $ngay1 == 18){ ?> selected="selected" <?php } ?>>18</option>
      <option value="19" <?php if( $ngay1 == 19){ ?> selected="selected" <?php } ?>>19</option><option value="20" <?php if( $ngay1 == 20){ ?> selected="selected" <?php } ?>>20</option>
      <option value="09" <?php if( $ngay1 == 21){ ?> selected="selected" <?php } ?>>9</option><option value="22" <?php if( $ngay1 == 21){ ?> selected="selected" <?php } ?>>22</option>
      <option value="21" <?php if( $ngay1 == 23){ ?> selected="selected" <?php } ?>>21</option><option value="24" <?php if( $ngay1 == 23){ ?> selected="selected" <?php } ?>>24</option>
      <option value="25" <?php if( $ngay1 == 25){ ?> selected="selected" <?php } ?>>25</option><option value="26" <?php if( $ngay1 == 25){ ?> selected="selected" <?php } ?>>26</option>
      <option value="27" <?php if( $ngay1 == 27){ ?> selected="selected" <?php } ?>>27</option><option value="28" <?php if( $ngay1 == 27){ ?> selected="selected" <?php } ?>>28</option>
      <option value="29" <?php if( $ngay1 == 29){ ?> selected="selected" <?php } ?>>29</option><option value="30" <?php if( $ngay1 == 30){ ?> selected="selected" <?php } ?>>30</option>
    </select>
     </label>
      
      <label>Tháng 
      <select name="thang1" id="mh" style="min-width:50px;">
      <option value="01" <?php if( $thang1 == 1){ ?> selected="selected" <?php } ?>>1</option><option value="02" <?php if( $thang1 == 2){ ?> selected="selected" <?php } ?>>2</option>
      <option value="03" <?php if( $thang1 == 3){ ?> selected="selected" <?php } ?>>3</option><option value="04" <?php if( $thang1 == 4){ ?> selected="selected" <?php } ?>>4</option>
      <option value="05"<?php if( $thang1 == 5){ ?> selected="selected" <?php } ?>>5</option><option value="06" <?php if( $thang1 == 6){ ?> selected="selected" <?php } ?>>6</option>
      <option value="07" <?php if( $thang1 == 7){ ?> selected="selected" <?php } ?>>7</option><option value="08" <?php if( $thang1 == 8){ ?> selected="selected" <?php } ?>>8</option>
      <option value="09" <?php if( $thang1 == 9){ ?> selected="selected" <?php } ?>>9</option><option value="10" <?php if( $thang1 == 10){ ?> selected="selected" <?php } ?>>10</option>
      <option value="11" <?php if( $thang1 == 11){ ?> selected="selected" <?php } ?>>11</option><option value="12" <?php if( $thang1 == 12){ ?> selected="selected" <?php } ?>>12</option>

	  </select>
      </label>
      
      <label>Năm 
      <select name="nam1">
      <?php 
	  $t=date('Y')-1900;
	  for($i=1; $i<=$t; $i++){
		  $n=1900+$i;
	?>
    <option <?php if( $nam1 == $n){ ?> selected="selected" <?php } ?>><?php echo $n ?></option>
    <?php
	} ?>

      </select>
      </label> 
                    </td>
    			</tr>
				 <tr class="row1"> 
				   <td width="29%"><div style="text-align: right; font-weight: bold;">Ngày khai giảng:</div>      				</td>
				   <td width="71%">    
     <label style="margin-left:10px;">Ngày 
    <select name="ngay2">
           <option value="01" <?php if( $ngay1 == 1){ ?> selected="selected" <?php } ?>>1</option><option value="02" <?php if( $ngay1 == 2){ ?> selected="selected" <?php } ?>>2</option>
      <option value="03" <?php if( $ngay2 == 3){ ?> selected="selected" <?php } ?>>3</option><option value="04" <?php if( $ngay2 == 4){ ?> selected="selected" <?php } ?>>4</option>
      <option value="05"<?php if( $ngay2 == 5){ ?> selected="selected" <?php } ?>>5</option><option value="06" <?php if( $ngay2 == 6){ ?> selected="selected" <?php } ?>>6</option>
      <option value="07" <?php if( $ngay2 == 7){ ?> selected="selected" <?php } ?>>7</option><option value="08" <?php if( $ngay2 == 8){ ?> selected="selected" <?php } ?>>8</option>
      <option value="09" <?php if( $ngay2 == 9){ ?> selected="selected" <?php } ?>>9</option><option value="10" <?php if( $ngay2 == 10){ ?> selected="selected" <?php } ?>>10</option>
      <option value="11" <?php if( $ngay2 == 11){ ?> selected="selected" <?php } ?>>11</option><option value="12" <?php if( $ngay2 == 12){ ?> selected="selected" <?php } ?>>12</option>
      <option value="13" <?php if( $ngay2 == 13){ ?> selected="selected" <?php } ?>>13</option><option value="14" <?php if( $ngay2 == 14){ ?> selected="selected" <?php } ?>>14</option>
      <option value="15" <?php if( $ngay2 == 15){ ?> selected="selected" <?php } ?>>15</option><option value="16" <?php if( $ngay2 == 16){ ?> selected="selected" <?php } ?>>16</option>
      <option value="17" <?php if( $ngay2 == 17){ ?> selected="selected" <?php } ?>>17</option><option value="18" <?php if( $ngay2 == 18){ ?> selected="selected" <?php } ?>>18</option>
      <option value="19" <?php if( $ngay2 == 19){ ?> selected="selected" <?php } ?>>19</option><option value="20" <?php if( $ngay2 == 20){ ?> selected="selected" <?php } ?>>20</option>
      <option value="09" <?php if( $ngay2 == 21){ ?> selected="selected" <?php } ?>>9</option><option value="22" <?php if( $ngay2 == 21){ ?> selected="selected" <?php } ?>>22</option>
      <option value="21" <?php if( $ngay2 == 23){ ?> selected="selected" <?php } ?>>21</option><option value="24" <?php if( $ngay2 == 23){ ?> selected="selected" <?php } ?>>24</option>
      <option value="25" <?php if( $ngay2 == 25){ ?> selected="selected" <?php } ?>>25</option><option value="26" <?php if( $ngay2 == 25){ ?> selected="selected" <?php } ?>>26</option>
      <option value="27" <?php if( $ngay2 == 27){ ?> selected="selected" <?php } ?>>27</option><option value="28" <?php if( $ngay2 == 27){ ?> selected="selected" <?php } ?>>28</option>
      <option value="29" <?php if( $ngay2 == 29){ ?> selected="selected" <?php } ?>>29</option><option value="30" <?php if( $ngay2 == 30){ ?> selected="selected" <?php } ?>>30</option>
    </select>
     </label>
      
      <label>Tháng 
      <select name="thang2" id="mh" style="min-width:50px;">
      <option value="01" <?php if( $thang2 == 1){ ?> selected="selected" <?php } ?>>1</option><option value="02" <?php if( $thang2 == 2){ ?> selected="selected" <?php } ?>>2</option>
      <option value="03" <?php if( $thang2 == 3){ ?> selected="selected" <?php } ?>>3</option><option value="04" <?php if( $thang2 == 4){ ?> selected="selected" <?php } ?>>4</option>
      <option value="05"<?php if( $thang2 == 5){ ?> selected="selected" <?php } ?>>5</option><option value="06" <?php if( $thang2 == 6){ ?> selected="selected" <?php } ?>>6</option>
      <option value="07" <?php if( $thang2 == 7){ ?> selected="selected" <?php } ?>>7</option><option value="08" <?php if( $thang2 == 8){ ?> selected="selected" <?php } ?>>8</option>
      <option value="09" <?php if( $thang2 == 9){ ?> selected="selected" <?php } ?>>9</option><option value="10" <?php if( $thang2 == 10){ ?> selected="selected" <?php } ?>>10</option>
      <option value="11" <?php if( $thang2 == 11){ ?> selected="selected" <?php } ?>>11</option><option value="12" <?php if( $thang2 == 12){ ?> selected="selected" <?php } ?>>12</option>

	  </select>
      </label>
      
      <label>Năm 
      <select name="nam2">
      <?php 
	  $t=date('Y')-1900;
	  for($i=1; $i<=$t; $i++){
		  $n=1900+$i;
	?>
    <option <?php if( $nam2 == $n){ ?> selected="selected" <?php } ?>><?php echo $n ?></option>
    <?php
	} ?>
      </select>
      </label> 
      </td>
			    </tr>

    			  <tr class="row0"> 
    					    
		      		<td valign="top" width="29%">&nbsp;</td>
		      		<td width="71%">&nbsp;</td>		    
	    			</tr>
	  			  </table>
 		</td>
  	</tr>
</tbody></table>


</div>
</div>
</form>
<?php
}//ket thuc update

?>

</div>
